<script type="text/javascript">
//<![CDATA[
    /*设置背景banner*/
    (function($) {  
        $('.em-wrapper-main').css({"margin-top":"2rem","position":"relative","background":"#fd393b"});
        $('.em-wrapper-main >div').css({"margin-top":"0","padding-top":"0"});
        var bane = '<div class="page_top_banner"><ul class="fashion_activity_banner"><li class="_top_banner01"></li><li class="_top_banner02"></li><li class="_top_banner03"></li><li class="_top_banner04"></li><li class="_top_banner05"></li><li class="_top_banner06"></li><li class="_top_banner07"></li><li class="_top_banner08"></li><li class="_top_banner09"></li><li class="_top_banner10"></li><li class="_top_banner11"></li><li class="_top_banner12"></li><li class="_top_banner13"></li><li class="_top_banner14"></li><li class="_top_banner15"></li><li class="_top_banner16"></li></ul></div>';      
        $('.em-wrapper-main > .container').before(bane);            
    })(jQuery); 
//]]>
</script>

<?php
//产品配置项
$home_url    =  Mage::getBaseUrl();
$data = Mage::helper('promoteevents')->getEvents('fashion_products_collection');
$recommandProductsImgSize = '320';
$productsImgSize = '190';
$product_sku_01 = $data->getRecommandProducts($recommandProductsImgSize);
$product_sku_02 = $data->getProducts($productsImgSize);
$page_nav       = $data->getCategoryTitle();


//配置活动时间段
$starttimestr = $data->getEventsFromDate();
$endtimestr = $data->getEventsToDate();

/* slider config */
$idJs = "em_minifilter_products_".md5(uniqid(rand()));    
if ($this->getData('slider_unique_id'))
$idJs = $this->getData('slider_unique_id');
$this->idJs = $idJs;

$key1 = array_keys($product_sku_01);
$key2 = array_keys($product_sku_02);
$key  =array_merge ($key1,$key2);
foreach (array_unique($key) as $value) {
    $landing_page_nav[] = $value;
}


?>

<!-- 活动倒计时 -->
<?php
    date_default_timezone_set('Europe/Moscow');
    $nowtime = time();
    //活动时间段转换为时间戳
    $starttime = strtotime($starttimestr) + 3*3600;
    $endtime = strtotime($endtimestr) + 3*3600;
?>
<script type="text/javascript">
//<![CDATA[
    jQuery(function($){
        var page_endtime = '<div class="append_div"><div class="countdown_patry"><div class="countdown_patry_end"><div class="endtime"><div><p><?php echo $this->__("The Promotion Has Ended.") ?></p></div><div><h2><?php echo $this->__("Thanks For Your Attenyion.");  ?></h2></div><div class="endtime_submit"><a href="<?php echo Mage::getBaseUrl(); ?>"><?php echo $this->__("Continue Shopping"); ?></a></div></div></div></div></div>';
        var page_starttime = '<div class="append_div"><div class="countdown_patry"><div class="countdown_patry_time"><div class="countdown_span"><?php echo $this->__("Deal Start in:"); ?></div><div class="patry" ><div class="patry_s"><div id="RemainD">00</div><div class="text_party">:</div><div id="RemainH">00</div><div class="text_party">:</div><div id="RemainM">00</div><div class="text_party">:</div><div id="RemainS">00</div></div><div><div><?php echo $this->__("days"); ?></div><div></div><div><?php echo $this->__("hours")?></div><div></div><div><?php echo $this->__("minutes"); ?></div><div></div><div><?php echo $this->__("seconds"); ?></div></div></div></div></div></div>';

        var interval = 1000; 
        var nowtime   =  "<?php echo $nowtime; ?>"; //当前时间
        var starttime = "<?php echo $starttime; ?>";//开始时间
        var endtime   = "<?php echo $endtime; ?>";//结束时间
        var now = new Date();
        var nowtime_s = now.getTime() - nowtime*interval;//php时间与js时间差；
        if(nowtime < starttime){
            var seconds  = starttime;//活动开始时间           
            $('body').append(page_starttime);
            window.setInterval(function(){ShowCountDown();}, interval); 
        }
        if(nowtime > endtime){//活动结束时间
            $('body').append(page_endtime);
        }
        
        function ShowCountDown() 
        { 
            var now        = new Date();
            var now_js     = now.getTime() + nowtime_s;
            var leftTime   = seconds*1000 - now_js; 
            var leftsecond = parseInt(leftTime/1000);
            var day1=Math.floor(leftsecond/(60*60*24)); 
            var hour=Math.floor((leftsecond-day1*24*60*60)/3600); 
            var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60); 
            var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60); 
            document.getElementById("RemainD").innerHTML = day1; 
            document.getElementById("RemainH").innerHTML = hour;
            document.getElementById("RemainM").innerHTML = minute;
            document.getElementById("RemainS").innerHTML = second;
            if(day1 == "0"  && hour == "0" && minute == "0" && second == "0" ){
                $('.append_div').remove();
            }
        } 
        

    });
//]]>
</script>
<!-- 活动倒计时 -->



<div class="fashion_products_collection">

<div class="landing-page">
    <div class="landing_page_banner"><a href="" style="display: table;height: 800px;width: 100%"></a></div>
   
    <div class="landing_page_product">
        <div class="page_coupon"><h3><a target="_blank" href="<?php echo $home_url  ?>promoteevents/events/index/type/online_offer#coupon_code"><?php echo $this->__("How to get my coupon?") ?></a></h3></div>
        <div class="landing_page_nav" id="landing_page_nav">
            <div> 
                <div class="page_navs">
                    <?php foreach ($landing_page_nav as $val): ?>
                        <a><span><?php echo $page_nav[$val]; ?></span></a>
                    <?php endforeach ?>
                </div>  
                <div class="page_navls"></div> 
            </div>
        </div>
        <div class="landing_page_centent ">
        
            <div id="<?php echo $idJs ; ?>" class="main_product">
<?php foreach ($landing_page_nav as $key => $main_product): ?>
    <div class="main_product_<?php echo $key; ?>" style="display: none;">
    <?php if ($product_sku_01[$main_product]): ?>
        <div class="product_tment_fashion">
            <div class="tment_fashion_left"></div>
            <span><?php echo $page_nav[$main_product]; ?></span>
            <div class="tment_fashion_right"></div>
        </div>

        <?php foreach ($product_sku_01[$main_product] as $_product): ?>
            <div class="em-item-slider" >
                <div class="products-grid">
                <div class="item first" style="width: 100%">
                <div class="product-item">
                    <?php //Mage::helper('promoteevents')->isDisplayLabels($_product); ?> 
                    <div class="product-shop-top">
                        <a target="_blank" href="<?php echo $productUrl = $_product['url'] ?>" title="<?php echo $productName = $_product['name'] ?>" class="product-image ">
                            <img src="<?php echo $_product['thumbnail']; ?>" width="320" height="320" alt="<?php echo $productName; ?>" />
                        </a>
                        <div class="em-element-display-hover bottom">          
                            <ul class="add-to-links">
                                <li><a href="<?php echo $_product['wishlist'] ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="product-shop">
                        <div class="f-fix">
                                <!--product name-->
                                <h3 class="product-name"><a target="_blank" href="<?php echo $productUrl; ?>" title="<?php echo $productName; ?>"><?php echo $productName; ?></a></h3>
                                <!--product price-->
                                <?php 
                                    $price         = $_product['price'];
                                    $currencyPrice = $_product['currency_price'];
                                    $finalPrice    = $_product['final_price'];
                                    $currencyFinalPrice = $_product['currency_final_price'];
                                ?>
                                <div class="product_price">
                                    <?php if ($price == $finalPrice): ?>
                                        <span class="price"><?php echo $currencyPrice; ?></span>
                                    <?php else : ?>
                                        <span class="prices"><?php echo $currencyPrice; ?></span>
                                        <span class="finalPrice"><?php echo $currencyFinalPrice; ?></span>
                                    <?php endif ?>
                                </div>
                                <!-- Current Stcok -->
                                <div class="current_stcok">
                                    <span>
                                        <?php echo $this->__('Qty.'); ?><?php echo $_product['qty']; ?>
                                    </span>
                                    <?php if ($price != $finalPrice): ?>
                                        <?php 
                                            $price_stk = ($price-$finalPrice)/$price;
                                            $price_stks = number_format($price_stk,4);
                                            echo (Mage::app()->getStore()->getStoreId() == '2')?"Скидка ".$price_stks*100 . "%":$price_stks*100 . "% off";
                                        ?>
                                    <?php endif ?>
                                </div>
                                <!--Shop Now-->
                                <div class="em-btn-addto">
                                    <a target="_blank" href="<?php echo $productUrl ?>"><?php echo $this->__('Shop Now') ?></a>
                                </div>  
                            </div>
                    </div> 
                    <?php if($_product['qty'] == 0): ?>
                            <div class="page_instock"></div>
                    <?php endif ?> 
                </div>
                </div>
                </div>
            </div>     
            
        <?php endforeach ?>
        
        
    <?php endif ?>
    </div>
<?php endforeach ?>






            </div>
            <div class="product_tment"><hr/></div>
            <div class="entry_product">
<?php foreach ($landing_page_nav as  $key => $entry_product): ?>
    <div class="entry_product_<?php echo $key; ?>" style="display: none;">
    <?php if ($product_sku_02[$entry_product]): ?>
        <?php foreach ($product_sku_02[$entry_product] as $_product): ?>
                <div class="em-item-slider" style="width: <?php echo "190px"; ?>;display: inline-block;">
                    <div class="products-grid">
                    <div class="item first" style="width: 100%">
                    <div class="product-item">
                    <?php //Mage::helper('promoteevents')->isDisplayLabels($_product); ?> 
                    <div class="product-shop-top">
                        <a target="_blank" href="<?php echo $productUrl = $_product['url'] ?>" title="<?php echo $productName = $_product['name'] ?>" class="product-image ">
                            <img src="<?php echo $_product['thumbnail']; ?>" width="190" height="190" alt="<?php echo $productName; ?>" />
                        </a>
                        <div class="em-element-display-hover bottom">          
                            <ul class="add-to-links">
                                <li><a href="<?php echo $_product['wishlist'] ?>" class="link-wishlist" title="<?php echo $this->__('Add to Wishlist') ?>"><?php echo $this->__('Add to Wishlist') ?></a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="product-shop">
                       <div class="f-fix">
                                <!--product name-->
                                <h3 class="product-name"><a target="_blank" href="<?php echo $productUrl; ?>" title="<?php echo $productName; ?>"><?php echo $productName; ?></a></h3>
                                <!--product price-->
                                <?php 
                                    $price         = $_product['price'];
                                    $currencyPrice = $_product['currency_price'];
                                    $finalPrice    = $_product['final_price'];
                                    $currencyFinalPrice = $_product['currency_final_price'];
                                ?>
                                <div class="product_price">
                                    <?php if ($price == $finalPrice): ?>
                                        <span class="price"><?php echo $currencyPrice; ?></span>
                                    <?php else : ?>
                                        <span class="prices"><?php echo $currencyPrice; ?></span>
                                        <span class="finalPrice"><?php echo $currencyFinalPrice; ?></span>
                                    <?php endif ?>
                                </div>
                                <!-- Current Stcok -->
                                <div class="current_stcok">
                                    <span>
                                        <?php echo $this->__('Qty.'); ?><?php echo $_product['qty']; ?>
                                    </span>
                                    <?php if ($price!= $finalPrice): ?>
                                        <?php 
                                            $price_stk = ($price-$finalPrice)/$price;
                                            $price_stks = number_format($price_stk,4);
                                            echo (Mage::app()->getStore()->getStoreId() == '2')?"Скидка ".$price_stks*100 . "%":$price_stks*100 . "% off";
                                        ?>
                                    <?php endif ?>
                                </div>
                                <!--Shop Now-->
                                <div class="em-btn-addto">
                                    <a target="_blank" href="<?php echo $productUrl ?>"><?php echo $this->__('Shop Now') ?></a>
                                </div>  
                            </div>
                    </div> 
                    <?php if($_product['qty'] == 0): ?>
                        <div class="page_instock"></div>
                    <?php endif ?> 
                    </div>
                    </div>
                    </div>
                </div>
        <?php endforeach ?>
    <?php endif ?>
    </div>
<?php endforeach ?>
            </div>
        </div>
    </div>
</div>
    
</div>
<script type="text/javascript">
    //<![CDATA[
    jQuery(function($){
        $(".landing_page_nav a").click(function(){
            /*点击样式切换*/
            $(this).addClass('landing_nav').siblings().removeClass('landing_nav landing_navs');
            $(this).prev().addClass('landing_navs');
            /*点击显示商品切换*/
            var text_nav = $(this).index();
            $(".main_product_"+text_nav).addClass('landing_product').siblings().removeClass('landing_product');
            $(".entry_product_"+text_nav).addClass('landing_product').siblings().removeClass('landing_product');
        })
        $(".landing_page_nav a").last().addClass('last_nav');
        $(".page_navs").children().first().addClass('landing_nav');
        $('.main_product').children().first().addClass('landing_product');
        $('.entry_product').children().first().addClass('landing_product');   

        /*导航条随窗口滚动显示*/
        var landing_nav_top = $(".landing_page_nav div").offset().top;
        $(window).scroll(function () {
            if ($(window).scrollTop() > landing_nav_top-230) {
                $(".landing_page_nav >div").addClass("landing_nav_top");
                $(".page_coupon").addClass("page_coupons");
            }else{
                $(".landing_page_nav >div").removeClass("landing_nav_top");
                $(".page_coupon").removeClass("page_coupons");
            }
        });
        $(".page_navls").click(function(){ $(".page_navs").toggle(); });
    })
    //]]>
</script>

